//
//  MKAlert.swift
//  MKPhotoDetailDemo
//
//  Created by 劢克科技 on 2019/5/24.
//  Copyright © 2019 劢克科技. All rights reserved.
//

import UIKit

/// 自定义提示
///
/// - Parameter str: 提示信息
func MKAlert(str: String) {
    let label = UILabel()
    label.backgroundColor = #colorLiteral(red: 0.1152647345, green: 0.1152647345, blue: 0.1152647345, alpha: 1)
    label.text = str
    label.textColor = UIColor.white
    label.frame = CGRect(x: 0, y: 0, width: 200, height: 34)
    label.textAlignment = .center
    label.transform = CGAffineTransform(translationX: (UIScreen.main.bounds.width - label.frame.width) / 2, y: UIScreen.main.bounds.height - 100)
    label.layer.cornerRadius = 6
    label.clipsToBounds = true
    
    UIApplication.shared.keyWindow?.addSubview(label)
    
    UIView.animate(withDuration: 0.3, delay: 1.5, options: UIView.AnimationOptions.curveEaseOut, animations: {
        label.alpha = 0
    }) { (_) in
        label.removeFromSuperview()
    }
}
